package com.daihou.BCJ.decrease;

import com.daihou.model.ceres.EnvironmentEnum;
import com.daihou.utils.DHHttpUtil;
import com.daihou.utils.EnvironmentUtil;
import com.daihou.utils.ReadTxtFile;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import java.io.IOException;
import java.util.Map;

public class SelfApplyQuery {
	static Map<String, String> headers;

	@DataProvider(name = "data1")
	public Object[][] dp() throws Exception {
		return ReadTxtFile.readTxtByPath("txtFiles/decrease.txt");//注意前面没有"/"
	}

	@Test(dataProvider = "data1")
	public static void readData(String name,String url, String body, String expected) throws IOException {
		String lineTxt = EnvironmentUtil.getUrl(EnvironmentEnum.FRONT);
		headers = EnvironmentUtil.getHeaders();
		try {
			String result = DHHttpUtil.post_with_String(lineTxt+url, body, headers).toJSONString();
			System.out.println("== " + result);
			Assert.assertTrue(result.contains(expected));
		} catch (Exception e) {
			System.err.println(e.getMessage());
		}
	}
}